<!doctype html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>后台管理页面</title>

<!-- 引入样式 -->
<link rel="stylesheet" type="text/css" href="new/css/global.css">
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
<style lang="less" scoped>
	.home-container {
		height: 100%;
		margin: 0;
		padding: 0;
	}
	.el-header {
		background-color: #373d41;
		display: flex;
		justify-content: space-between;
		padding-left: 0;
		align-items: center;
		color: #fff;
		font-size: 20px;
	}

	.el-aside {
		background-color: #333744;
	}

	.el-main {
		background-color: #eaedf1;
	}

	.iconfont {
		margin-right: 10px;
	}

	.toggle-button {
		background-color: #4a5064;
		font-size: 10px;
		line-height: 24px;
		color: #fff;
		text-align: center;
		letter-spacing: 0.2em;
		cursor: pointer;
	}
	/* 在引入的css文件中写入这个*/
	[v-cloak]{
		display: none;
	}
</style>
</head>
<body>
<div class="app" id="adminIndex" v-cloak>
	<el-container  class="home-container">
		<el-header>
			<div>
				<img src="" alt="">
				<span>I 家政后台管理</span>
			</div>
			<el-menu type="info"
					 :default-active="activeIndex2"
					 class="el-menu-demo"
					 mode="horizontal"
					 @select="handleSelect"
					 background-color="#373d41"
					 text-color="#fff"
					 active-text-color="#ffd04b">
				<el-submenu index="1">
					<template slot="title"><i class="el-icon-s-custom"></i>我的工作台</template>
					<el-menu-item index="2-1" @click="logout"><i class="el-icon-remove"></i>退出</el-menu-item>
				</el-submenu>
			</el-menu>
		</el-header>
		<!-- 页面主体区域 -->
		<el-container>
			<!-- 侧边栏 -->
			<el-aside :width="'210px'">
				<!-- 侧边栏菜单区域 -->
				<el-menu background-color="#333744" text-color="#fff" active-text-color="#409EFF" unique-opened
						 :collapse="isCollapse"
						 :collapse-transition="false"
						 :default-active="activePath">
					<!-- 一级菜单 -->
					<template  v-for="item in menuList">
						<el-submenu v-if="item.children.length > 0" :index="item.id + ''" :key="item.id">
							<!-- 一级菜单的模板区域 -->
							<template slot="title">
								<span>{{item.menuName}}</span>
							</template>

							<!-- 二级菜单 -->
							<el-menu-item v-if="item.children" :index="subItem.path" v-for="subItem in item.children" :key="subItem.id" @click="saveNavState(subItem.path)">
								<template slot="title">
									<!-- 图标 -->
									<i class="el-icon-menu"></i>
									<!-- 文本 -->
									<span>{{subItem.menuName}}</span>
								</template>
							</el-menu-item>
						</el-submenu>
						<el-menu-item v-else  :index="item.path" :key="item.id" @click="saveNavState(item.path)">
							<!-- 一级菜单的模板区域 -->
							<template slot="title">
								<span>{{item.menuName}}</span>
							</template>
						</el-menu-item>
					</template>

				</el-menu>
			</el-aside>
			<!-- 右侧内容主体 -->
			<el-main>

			</el-main>
		</el-container>
	</el-container>
</div>

<script src="js/vue.js"></script>
<!-- Jquery Js -->
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.0/jquery.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/layer/2.3/layer.js"></script>
<!-- 引入组件库 -->
<script src="js/common.js"></script>
<script src="https://unpkg.com/element-ui/lib/index.js"></script>

<script>
var vm = new Vue({
	el : "#adminIndex",
	data : {
		type : 1,//是否是admin
		activeIndex2: '1',
		// 左侧菜单数据
		menuList: [],
		// 是否折叠
		isCollapse: false,
		// 被激活的链接地址
		activePath: ''
	},

	created() {
		this.getMenuList()
		this.activePath = window.sessionStorage.getItem('activePath')
	},
	methods: {
		getMenuList(){
			const that = this;
			HttpGet("/menu/getList",null,function(result){
				if (result.result == true){
					that.menuList = result.data;
				}
			})
		},
		handleSelect(){

		},
		logout() {
			layer.msg("用户退出成功",{icon:1,time:1500},function () {
				window.localStorage.clear()
				window.location.href="AdminLogin.html";
			});
		},
		// 点击按钮，切换菜单的折叠与展开
		toggleCollapse() {
			this.isCollapse = !this.isCollapse
		},
		// 保存链接的激活状态
		saveNavState(activePath) {
			window.localStorage.setItem('activePath', activePath)
			this.activePath = activePath
			window.location.href = activePath;
		}
	}
});

</script>

</body>
</html>
